package com.itheima.health.controller;

import com.itheima.health.dto.CheckGroupDTO;
import com.itheima.health.entity.QueryPageBean;
import com.itheima.health.entity.Result;
import com.itheima.health.service.CheckGroupService;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

@RestController
public class CheckGroupController {

    @Reference
    CheckGroupService checkGroupService;

    @GetMapping("checkgroup/findAll")
    @ApiOperation(value = "查询套餐方法",notes = "查询所有的套餐列表信息")
    public Result findAll(){
        return new Result(checkGroupService.findAll());
    }

    @PostMapping("checkgroup/findPage")
    public Result findPage(@RequestBody QueryPageBean queryPageBean){
        return new Result(checkGroupService.findPage(queryPageBean));
    }

    @PostMapping("checkgroup/addCheckGroup")
    public Result addCheckGroup(@RequestBody CheckGroupDTO checkGroupDTO){
        return new Result(checkGroupService.saveCheckGroup(checkGroupDTO));
    }

    @GetMapping("checkgroup/findCheckItemInfoByGroupId/{id}")
    public Result findCheckItemIdsByGroupId(@PathVariable("id") int id){
        return new Result(checkGroupService.findCheckItemInfoByGroupId(id));
    }

    @DeleteMapping("checkgroup/deleteCheckGroup/{id}")
    public Result deleteCheckGroup(@PathVariable("id") int id){
        return new Result(checkGroupService.deleteCheckGroup(id));
    }
}
